package com.hunan.api.catv.entity.enums;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.ObjectUtils;

/**
 * 腾讯云视频审核状态类型
 *
 * @Author: wangchao
 * @Date: 2020/11/27 10:36
 */
public enum VedioReviewEnum {

    /**
     * 正常
     */
    pass(1, "Pass"),

    /**
     * 疑似
     */
    review(6, "Reveiw"),

    /**
     * 违规
     */
    block(5, "Block");

    private final Integer code;

    private final String state;

    VedioReviewEnum(Integer code, String state) {
        this.code = code;
        this.state = state;
    }

    public Integer getCode() {
        return code;
    }

    public String getState() {
        return state;
    }

    public static VedioReviewEnum getResult(Integer code) {
        if (ObjectUtils.isEmpty(code)) {
            return VedioReviewEnum.block;
        }
        VedioReviewEnum[] rcs = VedioReviewEnum.values();
        for (VedioReviewEnum rc : rcs) {
            if (rc.getCode().equals(code)) {
                return rc;
            }
        }
        return null;
    }

    /**
     * 返回结果没有匹配就默认审核中
     */
    public static Integer getCode(String state) {
        if (StringUtils.isEmpty(state)) {
            return 2;
        }
        VedioReviewEnum[] rcs = VedioReviewEnum.values();
        for (VedioReviewEnum rc : rcs) {
            if (rc.getState().equals(state)) {
                return rc.getCode();
            }
        }
        return 2;
    }
}
